#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int splice(vector<int>& nums1, vector<int>& nums2)
    {
        int s1sum = 0, diff = 0, diffmax = 0;
        for (int i = 0; i < nums1.size(); i++) {
            s1sum += nums1[i];
            diff = max(diff, 0) + nums2[i] - nums1[i];
            diffmax = max(diff, diffmax);
        }
        return s1sum + diffmax;
    }
    int maximumsSplicedArray(vector<int>& nums1, vector<int>& nums2) {
        return max(splice(nums1, nums2), splice(nums2, nums1));
    }
};